﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace Lib
{
    public class ClientInfo
    {
        public const int BUFFER_LENGTH = 2048;
        public Dictionary<Socket, ClientInfo> ClientList = new Dictionary<Socket,ClientInfo>();
        private static ClientInfo ci = null;

        public ClientInfo GetClientBySock(Socket sock)
        {
            return ClientList[sock];
        }

        public string UserName { get; set; }
        public byte[] Buffer { get; set; }
        public Socket Socket { get; set; }

        public ClientInfo()
        {
            UserName = "";
            Buffer = new byte[BUFFER_LENGTH];
            Socket = null;
        }

        public static ClientInfo GetInstance()
        {
            if (ci == null) ci = new ClientInfo();
            return ci;
        }

        public void AddClient(ClientInfo client)
        {
            ClientList.Add(client.Socket, client);
        }
    }
}
